package main

import (
	"go-web-scaffold/api"
	"go-web-scaffold/middleware"
	"go-web-scaffold/router"
	"go-web-scaffold/tws"
	"log"

	"github.com/gin-gonic/gin"
)

func main() {
	instance := tws.New("config/global.json")
	instance.Use(func(ctx *gin.Context) {
		log.Println(ctx.RemoteIP())
	})
	instance.NotFound404Error("抱歉，访问的地址不存在")
	instance.Run(func(engine *gin.Engine) {
		sqliteDBInstance := api.GetdbInstance("db/go-web-scaffold.db")
		router.BindRouters(engine, instance.GetRouterManager(), sqliteDBInstance)
		engine.Use(middleware.RequestLogger())
	})
}
